<!--  -->

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Stock NameConsumer implementation for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</title>
</head>

<body
 text = "#000000"
 link = "#000fff"
 vLink= "#ff0f0f"
 aLink = "#0000ff"
 bgColor = "#ffffff">

<hr><h2>Stock NameConsumer implementation for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</h2><hr>

<h3>Implementation of StockNameConsumer interface</h3>

This interface is used as a callback interface used by the Stock Distributor server to notify Stock Broker clients 
of updates. This class is ALSO used as a signal handler to catch SIGINT and properly unsubscribe from the Stock 
Distributor server.<P>

The Stock_StockNameConsumer_i class is generated automatically by the IDL compiler (using the -GI flag),
which is a subclass of POA_Stock::StockNameConsumer class. <P>

<h4>Implementing the Constructor</h4>

<PRE>
    Stock_StockNameConsumer_i::Stock_StockNameConsumer_i (Stock_StockBroker_i &context,
                                                          const char *stock_name)
      : context_ (context),
        stock_name_ (stock_name)
</PRE>

The "context_" and "stock_name_" are two private members of the Stock_StockNameConsumer_i class. They stand for the
context of the StockNameConsumer object and the name of the stock to listen to respectively. <P>

<h4>Implementing the push_StockName () member function</h4>

The main steps of this function are described as follows: <P>

<li>Verify this is the correct stock: Check if the StockName parameter in this function is equal to
the "stock_name_" private member. If this is not the stock that we are interested in then we need to stop
and return.</li> <P>

<li>Get the quoter for the connection from the context_ private member.</li>

<PRE>
    Stock::StockQuoter_var quoter = context_->get_connection_quoter_info ();
</PRE>

<li>Request more information from the quoter.</li>

<PRE>
    Stock::StockInfo_var stock_info = quoter->get_stock_info (the_stockname->name());
</PRE>

<h4>Implementing the access operations of the cookie attribute.</h4>

<li>Get the cookie attribute:</li>

<PRE>
    return this->cookie_.in ();
</PRE>

<li>Set the cookie attribute:</li>

<PRE>
    this->cookie_ = cookie;
    cookie->_add_ref ();
</PRE>

<hr><b>Email: </b><a href="mailto:"</a<ADDRESS>shanshan.jiang@vanderbilt.edu</ADDRESS>

</body>

</html>
